<?php
	$css_list[0]['url'][] = './tpl/css/general.css';
	$css_list[0]['url'][] = './tpl/css/book.css';
	$js_list[0] = './public/js/jquery.masonry.js';
?>
<!--{template inc/header}-->
<div id="body" class="container_16">
	<div class="piece1 mt10 boxshadow">
        <div class="piece1_hd"></div>
        <div class="piece1_bd">
            <div class="dapei_nav">
                <a class="dapei_link fl look_current">精彩晒货</a>
                <a href="{u u/me}" class="fr look_link ">我要晒</a>
                <span class="fr show_with_them ">我就喜欢晒！做最喜欢的自己！</span>
            </div>
			<ul class="look_show clearfix">
                <!--{loop $look_bests $share}-->
				<li>
                     <a href="{$share['look_imgs'][0]['url']}" target="_blank" style="display:block;width:219px;height:234px;overflow:hidden;">
						<img class="lazyload" original="{getimg $share['look_imgs'][0]['img'] 468 468}" src="./tpl/images/lazyload.gif" scaleType="3" scaleWidth="219" scaleHeight="234"/>
                    </a>
                    <div class="user_desc r5">
                        <i class="heart fl">❤</i>
						<p class="dapei_desc">
							<!--{getuser $share['uid'] 0 '' 'uname icard'}-->:
							<!--{if empty($share['best_desc'])}-->
							<span>{cutstr $share['content'] 30}</span>
							<!--{else}-->
							<span>{$share['best_desc']}</span>
							<!--{/if}-->
						</p>
                    </div>
                </li>
				<!--{/loop}-->
			</ul>                  
        </div>
        <div class="piece1_ft"></div>
    </div>
	<div class="category_sort_all mt20" id="category_sort_all" >
		<div class="fl" style="margin:15px 0 0 0;">
			<ul class="mr10">
				<li class="category_sort_l">
					<a{if $type != 'goods'} class="c"{/if} href="{u look/index}">
						<i></i>
						<span title="全部搭配">全部晒货</span>
					</a>
				</li>
				<li class="category_sort_r" style="margin-left:-1px;">
					<a{if $type == 'goods'} class="c"{/if} href="{u look/index type=goods}">
						<span title="网购实拍">网购实拍</span>
						<i></i>
					</a>
				</li>
			</ul>
			<a style="font-size:14px;color:#666;float:left; padding:5px 0 0 0;">排序：</a>
			<ul>
				<li class="category_sort_l">
					<a{if $hot1_url['act'] == 1} class="c"{/if} href="{$hot1_url['url']}">
						<i></i>
						<span>{lang sort_1hot}</span>
					</a>
				</li>
				<li class="category_sort_c">
					<a{if $hot7_url['act'] == 1} class="c"{/if} href="{$hot7_url['url']}">
						<span>{lang sort_7hot}</span>
						<i></i>
					</a>
				</li>
				<li class="category_sort_r" style="margin-left:-1px;">
					<a{if $new_url['act'] == 1} class="c"{/if} href="{$new_url['url']}">
						<span>{lang sort_new}</span>
						<i></i>
					</a>
				</li>
			</ul>
		</div>
	</div>
	<div class="imagewall_nav">
		<div class="imagewall" id="imagewall_container">
			<div class="i_w_f i_w_f_f">
				<div class="hd"></div>
				<div class="bd" style="padding-top:0;">
					<div class="book_daren_nav">
						<b>晒货达人</b>
					</div>
					<ul class="book_daren_list">
						<!--{loop $look_darens $daren}-->
						<li>
							<a href="{u u/index uid=$daren['uid']}" target="_blank"><img class="fl avatar r3" src="{getimg $daren['img'] 100 100 1}"  height="80" /></a>
							<div class="daren_info">
								<!--{getuser $daren['uid'] 0 '' '' 'inc/getuser/book_look_daren'}-->
							</div>
					   </li>
					   <!--{/loop}-->
					</ul>
				</div>
				<div class="ft"></div>  
			</div>
			<!--{loop $share_list $share}-->
			<div class="i_w_f hide1" shareID="{$share['share_id']}" id="share_item_{$share['share_id']}">
				<div class="hd"></div>
				<div class="bd">
					<ul class="pic">
						<!--{eval $shipai_tag = '<span class="shipai_tag"></span>';}-->
						<!--{loop $share['look_imgs'] $share_img}-->
						<li>
							<!--{if isset($share['goods_imgs'])}-->
							{$shipai_tag}
							<!--{/if}-->
							<a style="width:200px;" href="{$share_img['url']}" target="_blank">
								<img class="book_img lazyload" original="{getimg $share_img['img'] 200 999}" width="200" src="./tpl/images/lazyload.gif" oldWidth="{$share_img['img_width']}" oldHeight="{$share_img['img_height']}"/>
							</a>
						</li>
						<!--{eval $shipai_tag = '';}-->
						<!--{/loop}-->
					</ul>
					<div class="favorite">
						<a href="javascript:;" class="favaImg" onclick="$.Fav_Share({$share['share_id']},this,32,'#share_item_{$share['share_id']}');"></a>
						<div class="favDiv"><a target="_blank" class="favCount SHARE_FAV_COUNT" href="{$share['url']}"  >$share['collect_count']</a></div>
						<a target="_blank" href="{$share['url']}" class="creply"><b>{$share['comment_count']}</b>评论</a>
					</div>
					<!--{if isset($share['goods_imgs'])}-->
					<ul class="googd_list_show">
						<!--{eval $index = 1;}-->
						<!--{loop $share['goods_imgs'] $share_img}-->
						<li>
							<span class="num_list">{$index}</span>
							<a class="link" target="_blank" href='{$share_img['url']}'>{cutstr $share_img['name'] 18}</a>&nbsp;
							<span class="price">{$share_img['price_format']}</span>
						</li>
						<!--{eval $index++;}-->
						<!--{/loop}-->
					</ul>
					<!--{/if}-->
				</div>
				<div class="who_share">
					<div class="ws_bd clearfix">
						<!--{getuser $share['uid'] 0 's,24' ',icard avt fl lazyload'}-->
						<p class="fr clearfix">
							<span class="t fl"><!--{getuser $share['uid'] 0 '' 'n icard'}--></span>
							<span class="t fr">{$share['time']}</span>
							<span class="tkinfo clearfix">
								{cutstr $share['content'] 200}
							</span>
						</p>
					</div>
					<div class="ws_ft"></div>
				</div>
			</div>
			<!--{/loop}-->
		</div>
		<!--{if $pager['page_count'] > 1}-->
		<div style="padding-top:30px" class="clr hide" id="pageBox">
			<div class="pagination"> 
				<!--{subtemplate inc/pages}--> 
			</div>
		</div>
		<!--{/if}-->
		<div class="clear"></div>
	</div>
</div>
<div id="pbLoading" style="background:url(./tpl/images/loading.gif) no-repeat center center;height:52px; display:none;"></div>
<div class="hide">
<!--{if $pager['page_count'] > 0}-->
<!--{loop $pb_list $url}-->
<a href="{$url}">{$url}</a>
<!--{/loop}-->
<!--{/if}-->
</div>
<script type="text/javascript">
var rowHtml = '<div class="i_w_f i_w_f_f empty_row"><div class="hd"></div><div class="bd" style="height:#HEIGHT#px;"></div><div class="ft"></div></div>';
var pbUrl = "{$pb_url}";
var imgWidth = 200;
var pbMaxIndex = {$_FANWE['setting']['share_pb_load_count']};
jQuery(function(){
	<!--{dynamic getShareByUserClickShareID}-->
	<!--{dynamic getManageDynamic args=book_look}-->
	$(".book_img").each(function(){
		var oldWidth = parseInt(this.getAttribute("oldWidth"));
		var oldHeight = parseInt(this.getAttribute("oldHeight"));
		if(isNaN(oldWidth) || isNaN(oldHeight) || oldWidth == 0 || oldHeight == 0)
		{
			this.height = 0;
		}
		else
		{
			var scale = imgWidth / oldWidth;
			this.height = oldHeight * scale;
		}
	});

	$('#imagewall_container').css({"height":"auto","background":"none"});
	$('.i_w_f').css("visibility","visible");
	
	$('#imagewall_container').masonry({
		itemSelector: '.i_w_f',
		isAnimated:true,
		gutterWidth:15,
		gutterHeight:8,
		columnWidth:225
	});

	<!--{if $pager['page_count'] > 0}-->
	createPBScroll(pbUrl,appendShareItem,pbLoadingFun,2,pbMaxIndex,300);
	<!--{/if}-->
});

function appendBottomItem()
{
	var lefts = new Object();
	var colTotal = 4;
	$(".i_w_f").each(function(i){
		if($(this).position().top == 0)
		{
			lefts['l'+$(this).position().left] = $(this);
		}
		else
		{
			if(lefts['l'+$(this).position().left].position().top <  $(this).position().top)
				lefts['l'+$(this).position().left] = $(this);
		}
	});
	
	var cols = 0;
	var maxLeft = '';
	var currentSize = 0;
	var maxSize = 0;
	for(var left in lefts)
	{
		cols++;
		currentSize = lefts[left].position().top + lefts[left].height();
		if(currentSize > maxSize)
		{
			maxLeft = left;
			maxSize = currentSize;
		}
	}
	
	var htmlArray = new Array();
	var htmlObjs = new Object();
	html = '';
	for(var left in lefts)
	{
		currentSize = lefts[left].position().top + lefts[left].height();
		if(currentSize < maxSize)
		{
			htmlObjs['h'+(maxSize - currentSize)] = rowHtml.replace("#HEIGHT#",maxSize - currentSize - 30);
			htmlArray.push(maxSize - currentSize);
		}
	}

	var newArray = htmlArray.sort(function(a,b){
		if(a > b)
			return -1;
		else if(a < b)
			return 1;
		else
			return 0;
	});
	
	for(var h=0;h<newArray.length;h++)
	{
		html += htmlObjs['h'+newArray[h]];
	}

	if(colTotal > cols)
	{
		for(var i=0; i< (colTotal - cols);i++)
		{
			html = rowHtml.replace("#HEIGHT#",maxSize - 22) + html;
		}
	}
	html = $('<div>' + html + '</div>').find('.i_w_f');
	$('#imagewall_container').append(html).masonry('appended',html,true);
}

function appendShareItem(result,index)
{
	html = '<div>' + result + '</div>';
    html = $(html).find('.i_w_f');
	$(".book_img",html).each(function(){
		var oldWidth = parseInt(this.getAttribute("oldWidth"));
		var oldHeight = parseInt(this.getAttribute("oldHeight"));
		if(isNaN(oldWidth) || isNaN(oldHeight) || oldWidth == 0 || oldHeight == 0)
		{
			this.height = 0;
		}
		else
		{
			var scale = imgWidth / oldWidth;
			this.height = oldHeight * scale;
		}
	});
	$('#imagewall_container').append(html).masonry('appended',html,true,function(){
		if(index >= pbMaxIndex || result == '')
		{
			$("#pageBox").show();
			var fun = function(){
				appendBottomItem();
			}
			setTimeout(fun,1000);
		}
	});
}

function pbLoadingFun(bln)
{
	if(bln)
		$("#pbLoading").show();
	else
		$("#pbLoading").hide();
}

function ShowUserClickShare(result)
{
	if($("#share_item_" + result.share_id).length > 0)
	{
		var thisshare = $("#share_item_" + result.share_id);
		$("#imagewall_container").prepend(thisshare);
	}
	else
		$("#imagewall_container").prepend(result.html);
}

function BookUpdateUserFollow(obj,result)
{
	var parent = $(obj).parent();
	if(result.status == 1)
	{
		parent.html('<span class="followed">已关注</span>');
	}
}
</script>
<!--{template inc/footer}-->
